{layout name="layout" /}
<fieldset class="layui-elem-field">
    <legend>定时任务 - 新增</legend>
    <div class="layui-field-box">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">分钟：</label>
                <div class="layui-input-inline">
                    <input type="text" name="minute" lay-verify="crontab" placeholder="请输入分钟" autocomplete="off" class="layui-input" value='{$data.name|default=""}' >
                </div>
                <div class="layui-form-mid layui-word-aux" data-val="*">每分钟</div>
                <div class="layui-form-mid layui-word-aux" data-val="*/5">每五分钟</div>
                <div class="layui-form-mid layui-word-aux" data-val="10,40">第10、40分钟</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">小时：</label>
                <div class="layui-input-inline">
                    <input type="text" name="hour" lay-verify="crontab" placeholder="请输入小时" autocomplete="off" class="layui-input" value='{$data.hour|default=""}'>
                </div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">日期：</label>
                <div class="layui-input-inline">
                    <input type="text" name="day" lay-verify="crontab" placeholder="请输入日期" autocomplete="off" class="layui-input" value='{$data.day|default=""}'>
                </div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">月份：</label>
                <div class="layui-input-inline">
                    <input type="text" name="month" lay-verify="crontab" placeholder="请输入月份" autocomplete="off" class="layui-input" value='{$data.month|default=""}'>
                </div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">周：</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="week[0]" title="周一" value="1" checked="">
                    <input type="checkbox" name="week[1]" title="周二" value="2" checked="">
                    <input type="checkbox" name="week[2]" title="周三" value="3" checked="">
                    <input type="checkbox" name="week[3]" title="周四" value="4" checked="">
                    <input type="checkbox" name="week[4]" title="周五" value="5" checked="">
                    <input type="checkbox" name="week[5]" title="周六" value="6" checked="">
                    <input type="checkbox" name="week[6]" title="周日" value="0" checked="">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formScheduled">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</fieldset>
<script type="text/javascript">
    layui.use(['form'], function() {
        var form = layui.form(), layer = layui.layer, $ = layui.jquery;
        form.verify({
            crontab: function(value) {
                var regxp = /^((((\d+-\d+)|(\*))(\/\d+)?)|[\d+,])+$/;
                if (!regxp.test(value)) {
                    return '格式不正确';
                }
            }
        });
        form.on('submit(formScheduled)', function(data) {       //表单的提交
            $.ajax("{:url('')}", {type: 'POST', dataType: 'json', data: data.field,
                success: function(json) {
                    if (!json.code) {
                        return;
                    }
                    $('.layui-form')[0].reset();    //重置表单
                }
            });
            return false; //阻止表单跳转,如果需要表单跳转，去掉这段即可。
        });
    });
</script>